package com.example.shardingsphere.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.shardingsphere.demo.entity.OrderPayment;
import com.example.shardingsphere.demo.mapper.OrderPaymentMapper;
import com.example.shardingsphere.demo.service.IOrderPaymentService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Sunny
 * @since 2021-01-23
 */
@Service
public class OrderPaymentServiceImpl extends ServiceImpl<OrderPaymentMapper, OrderPayment> implements IOrderPaymentService {

    @Override
    public List<OrderPayment> listOrderPayments(String orderNo) {
        LambdaQueryWrapper<OrderPayment> query = Wrappers.lambdaQuery();
        query.eq(OrderPayment::getOrderNo, orderNo);
        return list(query);
    }

    @Override
    public boolean deleteOrder(String orderNo) {
        LambdaQueryWrapper<OrderPayment> query = Wrappers.lambdaQuery();
        query.eq(OrderPayment::getOrderNo, orderNo);
        return remove(query);
    }
}
